﻿Public Class Organization

	Public Shared Function Chart(ByVal ownerOfficerId As String, ByVal officerAppId As String) As List(Of Entity.ChartItem)

		If Not DL.Officer.CheckUserInDownline(ownerOfficerId, officerAppId) Then
			Throw New Exception("ท่านไม่สามารถดูแผนผังองค์กรที่ท่านไม่ได้สังกัดอยู่ได้")
		End If

		Return Chart(DL.Officer.GetOfficerId(officerAppId))
	End Function

	Public Shared Function Chart(ByVal officerId As String) As List(Of Entity.ChartItem)

		Dim objReturn As List(Of Entity.ChartItem)
		Dim t As New RWN.DL.Organization
		Dim dt As DataTable = t.LoadDataOrganizationData(officerId)
		objReturn = New List(Of Entity.ChartItem)

		If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
			objReturn = SS.ORM.Broker.RetrieveInstance(Of Entity.ChartItem)(dt)
			Return objReturn
		Else
			Return Nothing
		End If

	End Function

End Class
